<template>
	<view class="">
		<view class="discuss-item" v-for="(item,index) in list" :key="index">
			<view class="discussant flex">
				<image :src="item.headimg" mode="aspectFill" class="discuss-img" />
				<view class="">
					<view class="discussant-name">{{item.nickname}}</view>
					<view class="c-gray">{{item.createdate}}</view>
				</view>
			</view>
			<view class="discuss-content">{{item.speechs}}</view>
			<view class="flex align img-box" v-if="item.pics">
				<image v-for="(v,i) in item.pics" :key="i" :src="v" mode="aspectFill" class="discuss-image" @click="previewImg(i,item.pics)" />
			</view>
			<view class="flex align like-num">
				<image v-if="item.islike!=0" src="https://wx.2024csnl.com/static/goods/draw-liked.png" mode="aspectFill" class="discuss-like" @click.stop="onGetLike(item.id)"  />
				<image v-else  src="https://wx.2024csnl.com/static/goods/draw-like.png" mode="aspectFill" class="discuss-like" @click.stop="onGetLike(item.id)" />
				<view class="">{{item.like}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getPrizesHistoryMsg,
		givePrizesLike
	} from "../../api/index.js"
	export default {
		data() {
			return {
				list: [],
				id:'',
			}
		},
		onLoad(opt) {
			this.id=opt.id
			this.onGetPrizesHistoryMsg()
		},
		methods: {
			//点击预览图片
			previewImg(current,imgList) {
				uni.previewImage({
					current,
					urls: imgList,
					loop: true,
					indicator: "default"
				})
			},
			// 点赞
			async onGetLike(id) {
				const res=await givePrizesLike("s=/ApiChoujiang/dianzan",{
					id:id
				})
				const{status,msg}=res.data
				console.log(res,"res")
				this.showToast(msg)
				if(status==1){
					setTimeout(()=>{
						this.koiFish=[]
						this.onGetPrizesHistoryMsg()
					},2000)
				}
			},
			async onGetPrizesHistoryMsg(id) {
				const res = await getPrizesHistoryMsg(`s=/ApiChoujiang/beforeup&id=${this.id}`)
				const {
					msg,
					data,
					status
				} = res.data
				console.log(res, "res----")
				if (status == 1) {
					this.list = data
					// console.log(this.lotteryNums, 'rule')
				} else {
					this.showToast(msg)
				}
			}
		}
	}
</script>

<style>
	page {
		background-color: #F7F7F7;
	}
</style>

<style lang="scss" scoped>
	.discuss-item {
		margin: 20rpx;
		padding: 20rpx;
		background-color: #FFF;
		border-radius: 20rpx;

		.discussant {
			font-size: 24rpx;
			margin-bottom: 24rpx;

			.discuss-img {
				width: 67rpx;
				height: 67rpx;
				border-radius: 50%;
				margin-right: 15rpx;
			}

			.discussant-name {
				font-size: 29rpx;
				font-weight: bold;
			}
		}

		.discuss-content {
			font-size: 27rpx;
		}

		.img-box {
			flex-wrap: wrap;
			margin: 20rpx 0 16rpx;

			.discuss-image {
				width: 216rpx;
				height: 216rpx;
				border-radius: 8rpx;
				margin-right: 10rpx;
			}

			.discuss-image:last-child {
				margin-right: 0;
			}
		}

		.like-num {
			font-size: 24rpx;
			justify-content: flex-end;

			.discuss-like {
				width: 34rpx;
				height: 34rpx;
				margin-right: 8rpx;
			}
		}

	}
</style>
